package com.janko.springbootbase.jvm;

import lombok.SneakyThrows;

/**
 * @Description 类文件说明
 * @Author nieyankang
 * @Version 1.0
 * @date {date} {time}
 */
public class T005_LoadClassByHand {
    //自定义类 class 双亲委派之后 上级是App 再上级是 ext 再上级就是bootstrap
    //如何去加载一个类

    public static void main(String[] args)  throws Exception{
        Class clazz = T005_LoadClassByHand.class.getClassLoader().loadClass("com.janko.springbootbase.jvm.T002_ClassLoaderLevel");
        //结果是： com.janko.springbootbase.jvm.T002_ClassLoaderLevel
        System.out.println(clazz.getName());
        //利用反射加载 class
        T002_ClassLoaderLevel  classLoaderLevel=(T002_ClassLoaderLevel)clazz.newInstance();
        classLoaderLevel.m();
    }
}
